import axios from 'axios';
import qs from 'query-string';

export interface ScoreChargeRecord {
  id: number;
  user_id: number;
  score: number;
  status: string;
  status_text: string;
  transaction_id?: string;
  out_trade_no?: string;
  created_at: string;
  paid_at: string;
}

export interface ScoreChargeListRes {
  list: ScoreChargeRecord[];
  total: number;
}

export interface ScoreChargeParams {
  user_id: number;
  current: number;
  pageSize: number;
}

/**
 * 获取用户充值记录
 */
export function queryScoreChargeList(params: ScoreChargeParams) {
  return axios.get<{ data: ScoreChargeListRes }>('/admin/score-charge/index', {
    params,
    paramsSerializer: (obj) => {
      return qs.stringify(obj);
    },
  });
}

export interface ScoreChargeForm {
  user_id: number;
  score: number;
}
/**
 * 充值/提现
 */
export function chargeScore(params: ScoreChargeForm) {
  return axios.post<{ data: ScoreChargeRecord }>('/admin/score-charge/charge', params);
}


